package com.lucnn.diamond.spring.config;

import com.lucnn.diamond.spring.bean.Red;
import com.lucnn.diamond.spring.condition.MyFactoryBean;
import com.lucnn.diamond.spring.condition.MyImportBeanDefinitionRegistry;
import com.lucnn.diamond.spring.condition.MyImportSelector;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Scope;

@Configuration
@Import({Red.class,MyImportSelector.class, MyImportBeanDefinitionRegistry.class})//id 默认全类名
public class ImportConfig {

    /**
     * 1.@Component[自己内部Controller @Service @Repository等]
     * 2.@Bean[导入第三方包]
     * 3.快速给容器导入组件
     *      1.@Import[]
     *      2.@ImportSelector（spring-boot常用）
     *      3.@ImportBeanDefinitionRegistry
     * 4.FactoryBean
     *      默认通过getObject
     *      获取当前用 &+name
     *
     */
    @Bean
    @Scope("prototype")
    public MyFactoryBean myFactoryBean(){
        return new MyFactoryBean();
    }

}
